package cn.wolfcode.web.controller;

import cn.wolfcode.common.exception.BusinessException;
import cn.wolfcode.common.web.CommonCodeMsg;
import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.OperateIntergralVo;
import cn.wolfcode.service.IUsableIntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/intergral")
public class IntegralController {
    @Autowired
    private IUsableIntegralService usableIntegralService;

    @RequestMapping("/alipayOnIntergral")
    public Result<Boolean> alipayOnIntergral(@RequestBody OperateIntergralVo vo) {
        if (StringUtils.isEmpty(vo)) {
            throw new BusinessException(CommonCodeMsg.PARAM_IS_EMPTY);
        }
        Boolean ret = usableIntegralService.alipayOnIntergral(vo);
        return Result.success(ret);

    }

    @RequestMapping("/refundOnIntegral")
    public Result<Boolean> refundOnIntegral(@RequestBody OperateIntergralVo vo) {
        if (StringUtils.isEmpty(vo)) {
            throw new BusinessException(CommonCodeMsg.PARAM_IS_EMPTY);
        }
        Boolean ret = usableIntegralService.refundOnIntegralTry(vo,null);
        return Result.success(ret);
    }

}
